package demo.struts2;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ValueStack;

import DAO.ControlDB;
import Entity.Contact;
public class SaveAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id;
	 private String firstname;
	   private String surname;
	   private String knownas;
	   private int officephone;
	   private int mobilephone;
	   private int sthomephone;
	   private String emailaddress;
	   private String managername;
	   private String contacttype;
	   private String bestcontactmethod;
	   private String jobrole;
	   private String workbase;
	   private String lobtitle;
	   private Boolean isactive;
	   Contact contact;
	   
	   @Override
	public String execute() throws Exception {
		   if(!this.firstname.equals("")&&!this.surname.equals("")&&!this.contacttype.equals("")){
			   contact = new Contact(this.id,this.firstname,this.surname,this.knownas,this.getOfficephone(),this.mobilephone,this.officephone,this.emailaddress,"sdfsdf",this.contacttype,this.bestcontactmethod,this.jobrole,this.workbase,this.lobtitle,true);
			  System.out.println(isactive);
			   ControlDB con=new ControlDB();
			   con.addContact(contact);
			   return "input";
		   }
		   else{
		   return "error";
		   }
	}
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getSurname() {
		return surname;
	}
	public void setSurname(String surname) {
		this.surname = surname;
	}
	public String getKnownas() {
		return knownas;
	}
	public void setKnownas(String knownas) {
		this.knownas = knownas;
	}
	public int getOfficephone() {
		return officephone;
	}
	public void setOfficephone(int officephone) {
		this.officephone = officephone;
	}
	public int getMobilephone() {
		return mobilephone;
	}
	public void setMobilephone(int mobilephone) {
		this.mobilephone = mobilephone;
	}
	public int getSthomephone() {
		return sthomephone;
	}
	public void setSthomephone(int sthomephone) {
		this.sthomephone = sthomephone;
	}
	public String getEmailaddress() {
		return emailaddress;
	}
	public void setEmailaddress(String emailaddress) {
		this.emailaddress = emailaddress;
	}
	public String getManagername() {
		return managername;
	}
	public void setManagername(String managername) {
		this.managername = managername;
	}
	public String getContacttype() {
		return contacttype;
	}
	public void setContacttype(String contacttype) {
		this.contacttype = contacttype;
	}
	public String getBestcontactmethod() {
		return bestcontactmethod;
	}
	public void setBestcontactmethod(String bestcontactmethod) {
		this.bestcontactmethod = bestcontactmethod;
	}
	public String getJobrole() {
		return jobrole;
	}
	public void setJobrole(String jobrole) {
		this.jobrole = jobrole;
	}
	public String getWorkbase() {
		return workbase;
	}
	public void setWorkbase(String workbase) {
		this.workbase = workbase;
	}
	public String getLobtitle() {
		return lobtitle;
	}
	public void setLobtitle(String lobtitle) {
		this.lobtitle = lobtitle;
	}
	public Boolean getIsactive() {
		return isactive;
	}
	public void setIsactive(Boolean isactive) {
		this.isactive = isactive;
	}
	
}
